

/*
 * @lc app=leetcode.cn id=14 lang=java
 *
 * [14] 最长公共前缀
 */

// @lc code=start
class Solution {
    public String longestCommonPrefix(String[] strs) {
        int minLength=Integer.MAX_VALUE;
        for(String str:strs){
            minLength=Math.min(str.length(), minLength);
        }
        StringBuffer sBuffer=new StringBuffer();
        for(int i=0;i<minLength;i++){
            char c=strs[0].charAt(i);
            for(String str:strs){
                if(str.charAt(i)!=c){
                    return sBuffer.toString();
                }
            }
            sBuffer.append(c);
        }
        return sBuffer.toString();
    }
}
// @lc code=end

